package com.imstlife.vending.utils;

import android.animation.ValueAnimator;
import android.view.animation.BounceInterpolator;
import android.widget.ImageView;

/**
 * Created by lihaifeng on 16/11/1.
 */
public class AnimatorUtil {

    public static ValueAnimator animalDrink(final ImageView ivDrink) {

        ValueAnimator animator = ValueAnimator.ofInt(200, 300);//抖动范围

        animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
            @Override
            public void onAnimationUpdate(ValueAnimator animation) {
                int curValue = (int) animation.getAnimatedValue();
                ivDrink.layout(ivDrink.getLeft(), curValue, ivDrink.getRight(), curValue + ivDrink.getHeight());
            }
        });


        animator.setDuration(2000);
        animator.setInterpolator(new BounceInterpolator());
        animator.setRepeatCount(10000);
        animator.start();
        return animator;

    }

}
